package interview.huawei.tjt.training.huaweijishitiku;

import java.util.ArrayList;
import java.util.HashSet;
import java.util.Scanner;

// 称砝码
public class HJ41 {

    public static void main(String[] args) {

        Scanner sc = new Scanner(System.in);

        while ( sc.hasNextInt() ) {
            HashSet<Integer> set = new HashSet<>();//存放所有可能的结果，不用担心重复问题
            // 初始化添加0
            set.add(0);
            int n = sc.nextInt();
            int[] w = new int[n];
            int[] num = new int[n];
            // 砝码的重量
            for ( int i = 0; i < n; i ++ ) {
                w[i] = sc.nextInt();
            }
            // 各个重量砝码的数量
            for ( int i = 0; i < n; i ++ ) {
                num[i] = sc.nextInt();
            }
            // 遍历砝码
            for ( int i = 0; i < n; i ++ ) {
                // 获取当前所有的结果
                ArrayList<Integer> list = new ArrayList<>(set);
                for ( int j = 1; j <= num[i]; j ++ ) {
                    for ( int k = 0; k < list.size(); k ++ ) {
                        set.add( list.get(k) + w[i] * j );
                    }
                }
            }
            System.out.println(set.size());
        }

    }

}
